<?php
/**
 +------------------------------------------------------------------------------
 * ProductAction控制器类
 +------------------------------------------------------------------------------
 * @category   view
 * @package  index
 * @subpackage  index
 * @author   朝闻道 <hydata@gmail.com>
 * @date 2011-1-6
 * @time  上午11:25:42
 +------------------------------------------------------------------------------
 */
class ProductAction extends CommonAction{
	/**
	   *显示产品列表
	   *@date 2011-1-6 / @time 上午11:25:58
	   */
	function index() {
		//显示产品列表
		$aid=Input::getVar($_GET['aid']);
		if(empty($aid)){
			$this->error(L("_err_id_null_"));
		}
		$dao=D("Arc");
		$arcinfo=$dao->where("id=$aid")->find();
		if($arcinfo){
			$cid=$arcinfo['cid'];
			$arcinfo['title']=$arcinfo[$this->plang['l'].'name'];
			$this->assign("arcinfo",$arcinfo);
		}else{
			$this->error(L("_err_id_null_"));
		}
		$lang=Input::getVar($_GET['lang']);
		$dao=D("Product");
		$condition['aid']=$aid;
		if($lang!='all'){
			$condition['plang']=empty($lang)?$this->lang:$lang;
		}
		$condition['pis_show']='1';
		$pnum=Input::getVar($_GET['pnum']);
		$pnum=empty($pnum)?25:$pnum;
		$count=$dao->where($condition)->count();
		$page=new ZQPage($count,$pnum,0,1);
		$pageshow = $page->show();
		$this->assign('pageshow',$pageshow);
		$list=$dao->where($condition)->order("ptime DESC")->page($page->getPage().",$pnum")->findAll();
		$this->assign('list',$list);
		$this->assign('dh',$this->cat_dh($cid,$this->plang['l']));
		$this->display();
	}//end index
	
	/**
	   *显示产品详情及相册
	   *@date 2011-1-6 / @time 上午11:26:34
	   */
	function detail() {
		//显示产品详情及相册
		$id=Input::getVar($_GET['id']);
		if(empty($id)){
			$this->error(L("_err_id_null_"));
		}
		$dao=D("Product");
		$condition['id']=$id;
		$condition['pis_show']='1';
		$detail=$dao->where($condition)->find();
		if(empty($detail)){
			$this->error(L("_err_id_null_"));
		}
		$this->assign('detail',$detail);
		
		$dao=D("Arc");
		$aid=$detail['aid'];
		$arcinfo=$dao->where("id=$aid")->find();
		if($arcinfo){
			$cid=$arcinfo['cid'];
			$arcinfo['title']=$arcinfo[$this->plang['l'].'name'];
			$this->assign("arcinfo",$arcinfo);
		}else{
			$this->error(L("_err_id_null_"));
		}
		$this->assign('dh',$this->cat_dh($cid,$this->plang['l']));
		$this->display();
	}//end detail
}//end ProductAction